﻿package com.mui.controls.scrollBarResizable
{
    import fl.controls.*;
    import fl.events.*;
    import fl.managers.*;
    import flash.events.*;
    import flash.text.*;

    public class ScrollBarResizableTextArea extends TextArea
    {
        static const SCROLL_BAR_STYLES:Object = {downArrowDisabledSkin:"downArrowDisabledSkin", downArrowDownSkin:"downArrowUpSkin", downArrowOverSkin:"downArrowOverSkin", downArrowUpSkin:"downArrowUpSkin", upArrowDisabledSkin:"upArrowDisabledSkin", upArrowDownSkin:"upArrowDownSkin", upArrowOverSkin:"upArrowOverSkin", upArrowUpSkin:"upArrowUpSkin", thumbDisabledSkin:"thumbDisabledSkin", thumbDownSkin:"thumbUpSkin", thumbOverSkin:"thumbOverSkin", thumbUpSkin:"thumbUpSkin", thumbIcon:"thumbIcon", trackDisabledSkin:"trackDisabledSkin", trackDownSkin:"trackDownSkin", trackOverSkin:"trackOverSkin", trackUpSkin:"trackUpSkin", repeatDelay:"repeatDelay", repeatInterval:"repeatInterval"};

        public function ScrollBarResizableTextArea()
        {
            this.tabChildren = false;
            return;
        }// end function

        override protected function configUI() : void
        {
            isLivePreview = checkLivePreview();
            var _loc_1:* = rotation;
            rotation = 0;
            var _loc_2:* = super.width;
            var _loc_3:* = super.height;
            var _loc_4:int = 1;
            super.scaleY = 1;
            super.scaleX = _loc_4;
            setSize(_loc_2, _loc_3);
            move(super.x, super.y);
            rotation = _loc_1;
            startWidth = _loc_2;
            startHeight = _loc_3;
            if (numChildren > 0)
            {
                removeChildAt(0);
            }
            tabChildren = true;
            textField = new TextField();
            addChild(textField);
            updateTextFieldType();
            _verticalScrollBar = new ResizableUIScrollBar();
            _verticalScrollBar.name = "V";
            _verticalScrollBar.visible = false;
            _verticalScrollBar.focusEnabled = false;
            copyStylesToChild(_verticalScrollBar, SCROLL_BAR_STYLES);
            _verticalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
            addChild(_verticalScrollBar);
            _horizontalScrollBar = new ResizableUIScrollBar();
            _horizontalScrollBar.name = "H";
            _horizontalScrollBar.visible = false;
            _horizontalScrollBar.focusEnabled = false;
            _horizontalScrollBar.direction = ScrollBarDirection.HORIZONTAL;
            copyStylesToChild(_horizontalScrollBar, SCROLL_BAR_STYLES);
            _horizontalScrollBar.addEventListener(ScrollEvent.SCROLL, handleScroll, false, 0, true);
            addChild(_horizontalScrollBar);
            textField.addEventListener(TextEvent.TEXT_INPUT, handleTextInput, false, 0, true);
            textField.addEventListener(Event.CHANGE, handleChange, false, 0, true);
            textField.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown, false, 0, true);
            _horizontalScrollBar.scrollTarget = textField;
            _verticalScrollBar.scrollTarget = textField;
            addEventListener(MouseEvent.MOUSE_WHEEL, handleWheel, false, 0, true);
            return;
        }// end function

        public function setScrollBarSize(param1:Number) : void
        {
            horizontalScrollBar.setSize(param1, height);
            verticalScrollBar.setSize(param1, height);
            draw();
            return;
        }// end function

        override protected function drawLayout() : void
        {
            super.drawLayout();
            return;
        }// end function

        override protected function focusOutHandler(event:FocusEvent) : void
        {
            var _loc_2:* = focusManager;
            if (_loc_2)
            {
                _loc_2.defaultButtonEnabled = true;
            }
            super.focusOutHandler(event);
            if (editable)
            {
                setIMEMode(false);
            }
            return;
        }// end function

    }
}
